** 	Data construction for the district-level conflict panel and the India-level output numbers
**	Created: January 2021
**  Notes: Merging violence with mining and control data, creating variables
**  Creates: FINAL_Replication_Conflict, FINAL_Replication_Output
*************************************************************************************

set more off

cd "F:/Dropbox (ESOC - Princeton)/Public services and conflict in India/Mining/Restat_Repository"

*******************************************
* 1. Create Final_Replication_Conflict.dta
*******************************************

* Open daily conflict events and aggregate at the district by half-year
*-----------------------------------------------------------------------

u "INPUT_Conflict_Events", clear

gen semi=.
replace semi=1 if date_month=="January"
replace semi=1 if date_month=="February"
replace semi=1 if date_month=="March"
replace semi=1 if date_month=="April"
replace semi=1 if date_month=="May"
replace semi=1 if date_month=="June"
replace semi=2 if date_month=="July"
replace semi=2 if date_month=="August"
replace semi=2 if date_month=="September"
replace semi=2 if date_month=="October"
replace semi=2 if date_month=="November"
replace semi=2 if date_month =="December"

gen myhalf=yh(year,semi)


* Create violence measures
gen gov_killed=spo_attack+guard_attack+guard_targeted+spo_targeted+guard_other+spo_other+sf_killed
* Include all types of Security force killings. The raw data distinguishes between Special Police Officers, Home Guards, and main Police Forces; it further distinguishes between targeted killings of SPOs versus larger-scale attacks. For this study, the measure of Maoist attacks against the police includes all categories.
gen attacka=(gov_killed>0 & gov_killed!=.)
gen antiattacka=(mao_killed>0 & mao_killed!=.) & bomb==0
* Exclude incidents in which Maoists killed by their own bombs.


* Aggregate at the district half-year level
bys state district myhalf: egen attack=total(attacka)
bys state district myhalf: egen antiattack=total(antiattacka)

* Collapse violence data at the district state level
collapse (max) attack antiattack, by(district state myhalf year)

* Complete panel
drop if myhalf==.
egen st_dist_id=group(state district)
tsset st_dist_id myhalf
tsfill, full

* Complete missing observations
bys st_dist_id: egen district2=mode(district)
replace district=district2
bys st_dist_id: egen state2=mode(state)
replace state=state2
drop district2 state2
mvencode _all,mv(0) override

rename myhalf hdate
xtset st_dist_id hdate
keep if inrange(hdate,94,107)
drop year

* Merge to district-level, time-invariant variables
*---------------------
merge m:1 district state using  "INPUT_District_Constant"
drop _merge

* Merge to price time-series
*---------------------

merge m:1 hdate using "INPUT_Prices"
keep if _merge==3
drop _merge


* Create violence variables
*---------------------

gen log_antiattack=log(antiattack+1)
gen log_attack=log(attack+1)
gen hyp_attack=ln(attack+(attack^2+1)^0.5)
gen hyp_antiattack=ln(antiattack+(antiattack^2+1)^0.5)
gen attack_d=attack>0 & attack!=.
gen antiattack_d=antiattack>0 & antiattack!=.
gen antiattack_pc=antiattack*1000000/tot_pop
gen attack_pc=attack*1000000/tot_pop


label var attack_pc "Maoist attacks on Police (per million)"
label var antiattack_pc "Police attacks on Maoists (per million)"
lab var attack "Maoist Attacks on Police"
lab var hyp_attack "Maoist Attacks on Police (asinh)"
lab var hyp_antiattack "Police Attacks on Maoists (asinh)"
lab var attack_d "Maoist Attacks on Police (0/1)"
lab var antiattack_d "Police Attacks on Maoists (0/1)"
lab var antiattack "Police Attacks on Maoists"
lab var log_antiattack "Police Attacks on Maoists, Log (x+1)"
lab var log_attack "Maoist Attacks on Police, Log (x+1)"



* define treatment
*---------------------

gen post=hdate>=98
label var post "Post 2009 (inc.) dummy (0-1)"

* create mining variables
*---------------------

gen irondep_pa=irondep*1000/(tot_area) 
gen bauxdep_pa=bauxitedep*1000/(tot_area) 
gen coaldep_pa=coaldep/(tot_area) 
* Coal in Billion Tonnes per 1000 km2

gen log_irondep=log(irondep_pa+1)
gen log_bauxdep=log(bauxdep_pa+1)
gen log_coaldep=log(coaldep_pa+1)

gen irondep_pa1000=irondep*1000000/(tot_area) 
gen bauxdep_pa1000=bauxitedep*1000000/(tot_area) 
gen coaldep_pa1000=coaldep*1000/(tot_area)

gen irondep_pa100=irondep*100000/(tot_area) 
gen bauxdep_pa100=bauxitedep*100000/(tot_area) 
gen coaldep_pa100=coaldep*100/(tot_area)
 
gen irondep_pa10=irondep*10000/(tot_area) 
gen bauxdep_pa10=bauxitedep*10000/(tot_area) 
gen coaldep_pa10=coaldep*10/(tot_area)
 
gen irondep_padiv1000=irondep/(tot_area) 
gen bauxdep_padiv1000=bauxitedep/(tot_area) 
gen coaldep_padiv1000=coaldep/(tot_area*1000) 

gen irondep_padiv100=irondep*10/(tot_area) 
gen bauxdep_padiv100=bauxitedep*10/(tot_area) 
gen coaldep_padiv100=coaldep*10/(tot_area*1000) 

gen irondep_padiv10=irondep*100/(tot_area) 
gen bauxdep_padiv10=bauxitedep*100/(tot_area) 
gen coaldep_padiv10=coaldep*100/(tot_area*1000) 

gen log_irondep1000_post=post*(irondepdum>0)*(irondepdum!=.)* log(irondep_pa1000+1)
gen log_bauxdep1000_post=post*(bauxdepdum>0)*(bauxdepdum!=.)* log(bauxdep_pa1000+1)
gen log_coaldep1000_post=post*(coaldepdum>0)*(coaldepdum!=.)* log(coaldep_pa1000+1)

gen log_irondep100_post=post*(irondepdum>0)*(irondepdum!=.)* log(irondep_pa100+1)
gen log_bauxdep100_post=post*(bauxdepdum>0)*(bauxdepdum!=.)* log(bauxdep_pa100+1)
gen log_coaldep100_post=post*(coaldepdum>0)*(coaldepdum!=.)* log(coaldep_pa100+1)

gen log_irondep10_post=post*(irondepdum>0)*(irondepdum!=.)* log(irondep_pa10+1)
gen log_bauxdep10_post=post*(bauxdepdum>0)*(bauxdepdum!=.)* log(bauxdep_pa10+1)
gen log_coaldep10_post=post*(coaldepdum>0)*(coaldepdum!=.)* log(coaldep_pa10+1)


gen log_irondepdiv1000_post=post*(irondepdum>0)*(irondepdum!=.)* log(irondep_padiv1000+1)
gen log_bauxdepdiv1000_post=post*(bauxdepdum>0)*(bauxdepdum!=.)* log(bauxdep_padiv1000+1)
gen log_coaldepdiv1000_post=post*(coaldepdum>0)*(coaldepdum!=.)* log(coaldep_padiv1000+1)

gen log_irondepdiv100_post=post*(irondepdum>0)*(irondepdum!=.)* log(irondep_padiv100+1)
gen log_bauxdepdiv100_post=post*(bauxdepdum>0)*(bauxdepdum!=.)* log(bauxdep_padiv100+1)
gen log_coaldepdiv100_post=post*(coaldepdum>0)*(coaldepdum!=.)* log(coaldep_padiv100+1)


gen log_irondepdiv10_post=post*(irondepdum>0)*(irondepdum!=.)* log(irondep_padiv10+1)
gen log_bauxdepdiv10_post=post*(bauxdepdum>0)*(bauxdepdum!=.)* log(bauxdep_padiv10+1)
gen log_coaldepdiv10_post=post*(coaldepdum>0)*(coaldepdum!=.)* log(coaldep_padiv10+1)



gen log_irondep_post=post*(irondepdum>0)*(irondepdum!=.)* log(irondep_pa+1)
gen log_bauxdep_post=post*(bauxdepdum>0)*(bauxdepdum!=.)* log(bauxdep_pa+1)
gen log_coaldep_post=post*(coaldepdum>0)*(coaldepdum!=.)* log(coaldep_pa+1)

gen c_irondep_post=post*(irondepdum>0)*(irondepdum!=.)* (irondep_pa+1)
gen c_bauxdep_post=post*(bauxdepdum>0)*(bauxdepdum!=.)* (bauxdep_pa+1)
gen c_coaldep_post=post*(coaldepdum>0)*(coaldepdum!=.)* (coaldep_pa+1)


gen iron_post=post*irondepdum
gen baux_post=post*bauxitedepdum
gen coal_post=post*coaldepdum
gen manganese_post=post*manganesedepdum
gen chromite_post=post*chromitedepdum


* Create Price variables
*---------------------


rename q_avg_p_bauxite q_avg_p_baux
gen iron_price=(irondepdum)*log(q_avg_p_iron)
gen coal_price=(coaldepdum)*log(q_avg_p_coal)
gen baux_price=(bauxitedepdum)*log(q_avg_p_baux)

xtset st_dist hdate
sort hdate
bys st_dist: egen iron_price_av=mean(iron_price) if irondepdum!=0
bys st_dist: egen baux_price_av=mean(baux_price) if bauxdepdum!=0
bys st_dist: egen coal_price_av=mean(coal_price) if coaldepdum!=0

gen coal_price_st=coal_price-coal_price_av
gen baux_price_st=baux_price-baux_price_av
gen iron_price_st=iron_price-iron_price_av

label variable  coal_price_st  "Coal price (Log USD/MT)"
label variable baux_price_st  "Bauxite price (Log USD/MT)"
label variable iron_price_st  "Iron price (Log USD/MT)"

gen iron_value=(irondepdum)*log(irondep_pa+1)*log(q_avg_p_iron)
gen coal_value=(coaldepdum)*log(coaldep_pa+1)*log(q_avg_p_coal)
gen baux_value=(bauxitedepdum)*log(bauxdep_pa+1)*log(q_avg_p_baux)
gen manganese_price=(manganesedepdum)*log(q_avg_p_manganeseore)
gen chromite_price=(chromitedepdum)*log(q_avg_p_chromite)


gen iron_value1000=(irondep_pa1000>0)*log(irondep_pa1000+1)*log(q_avg_p_iron)
gen coal_value1000=(coaldep_pa1000>0)*log(coaldep_pa1000+1)*log(q_avg_p_coal)
gen baux_value1000=(bauxdep_pa1000>0)*log(bauxdep_pa1000+1)*log(q_avg_p_baux)

gen iron_valuediv1000=(irondep_padiv1000>0)*log(irondep_padiv1000+1)*log(q_avg_p_iron)
gen coal_valuediv1000=(coaldep_padiv1000>0)*log(irondep_padiv1000+1)*log(q_avg_p_coal)
gen baux_valuediv1000=(bauxdep_padiv1000>0)*log(irondep_padiv1000+1)*log(q_avg_p_baux)

gen iron_value100=(irondep_pa100>0)*log(irondep_pa100+1)*log(q_avg_p_iron)
gen coal_value100=(coaldep_pa100>0)*log(coaldep_pa100+1)*log(q_avg_p_coal)
gen baux_value100=(bauxdep_pa100>0)*log(bauxdep_pa100+1)*log(q_avg_p_baux)

gen iron_value10=(irondep_pa10>0)*log(irondep_pa10+1)*log(q_avg_p_iron)
gen coal_value10=(coaldep_pa10>0)*log(coaldep_pa10+1)*log(q_avg_p_coal)
gen baux_value10=(bauxdep_pa10>0)*log(bauxdep_pa10+1)*log(q_avg_p_baux)

gen iron_valuediv10=(irondep_padiv10>0)*log(irondep_padiv10+1)*log(q_avg_p_iron)
gen coal_valuediv10=(coaldep_padiv10>0)*log(coaldep_padiv10+1)*log(q_avg_p_coal)
gen baux_valuediv10=(bauxdep_padiv10>0)*log(bauxdep_padiv10+1)*log(q_avg_p_baux)

gen iron_valuediv100=(irondep_padiv100>0)*log(irondep_padiv100+1)*log(q_avg_p_iron)
gen coal_valuediv100=(coaldep_padiv100>0)*log(coaldep_padiv100+1)*log(q_avg_p_coal)
gen baux_valuediv100=(bauxdep_padiv100>0)*log(bauxdep_padiv100+1)*log(q_avg_p_baux)


* Time-treatment dummies
*---------------------


foreach mineral in "iron" "baux" "coal" {
	local i=94
	while `i'<=107 {
					gen `mineral'dep`i'=(`mineral'depdum>0)*(`mineral'depdum!=.)*(log(`mineral'dep_pa+1))*(hdate==`i')
					gen `mineral'depdum`i'=(`mineral'depdum>0)*(`mineral'depdum!=.)*(hdate==`i')
					local lab1=dofh(`i')
					display(`lab1')
					local lab2=halfyear(`lab1')
					display(`lab2')
					local lab3=year(`lab1')
					display(`lab3')
					local lab4=string(`lab3')+"h"+string(`lab2')
					display("`lab4'")
					label var `mineral'dep`i' "`lab4'"	
					label var `mineral'depdum`i' "`lab4'"				
			local i=`i'+1
			}
}


* Treatments for alternative mining measures
*-------------------------------------------

_pctile log_irondep if hdate==98 & irondepdum==1, p(5,10,20,25,50,90)
gen iron2=(log_irondep>=r(r5))*(log_irondep!=0)
label var iron2 "Iron Deposit (above median), 0-1"
gen iron2_post=iron_post*(log_irondep>=r(r5))*(log_irondep!=0)
label var iron2_post "Iron Deposit (above median) x Post"
gen ironsmalldrop_post=iron_post*(log_irondep>=r(r1))
label var ironsmalldrop_post "Iron Deposit x Post"
gen ironsmalldrop_price=iron_price*(log_irondep>=r(r1))
label var ironsmalldrop_price "Iron Deposit x Price (real USD per MT)"
gen iron2_price=iron_price*(log_irondep>=r(r5))
label var iron2_price "Iron Deposit (above median) x Price (real USD per MT)"


_pctile log_bauxdep if hdate==98 & bauxdepdum==1, p(5,10,20,25,50,90)
gen baux2_post=baux_post*(log_bauxdep>=r(r5))
label var baux2_post "Bauxite Deposit (above median) x Post"
gen baux2_price=baux_price*(log_bauxdep>=r(r5))
label var baux2_price "Bauxite Deposit (above median) x Price (real USD per MT)"
gen bauxsmalldrop_post=baux_post*(log_bauxdep>=r(r1))
label var bauxsmalldrop_post "Bauxite Deposit x Post"
gen bauxsmalldrop_price=baux_price*(log_bauxdep>=r(r1))
label var bauxsmalldrop_price "Bauxite Deposit x Price"


_pctile log_coaldep if hdate==98 & coaldepdum==1, p(5,10,20,25,50,90)
gen coal2_post=coal_post*(log_coaldep>=r(r5))
label var coal2_post "Coal Deposit (above median) x Post"
gen coal2_price=iron_price*(log_coaldep>=r(r5))
label var coal2_price "Coal Deposit (above median) x Price (real USD per MT)"
gen coalsmalldrop_post=coal_post*(log_coaldep>=r(r1))
label var coalsmalldrop_post "Coal Deposit x Post"
gen coalsmalldrop_price=coal_price*(log_coaldep>=r(r1))
label var coalsmalldrop_price "Coal Deposit x Price"




* Create district-level controls
*-------------------------------

gen r_tot_lit_rate = r_tot_lit/r_tot_pop
gen pop_dens = tot_pop/(tot_area*100)
gen r_tot_scst_rate=r_tot_sc/r_tot_pop+r_tot_st/r_tot_pop
gen r_share=r_tot_pop/(u_tot_pop+r_tot_pop)
gen r_tot_anyag_rate=r_tot_aglb/r_tot_pop+r_tot_cult/r_tot_pop


bys st_dist: egen max_iap_sanctioned=max(NumberofProjectssanctioned12)
bys st_dist: egen max_iap_takenup=max((NumberofProjectstakenup12))
bys st_dist: egen max_iap_completed=max((NumberofProjectsCompleted12))
gen any_iap=max_iap_sanctioned+max_iap_takenup+max_iap_completed>0 & max_iap_sanctioned+max_iap_takenup+max_iap_completed!=.
lab var NumberofProjectssanctioned12 "Number of IAP Projects sanctioned by 11-12"
lab var NumberofProjectstakenup12 "Number of IAP Projects taken up by 11-12"
lab var NumberofProjectsCompleted12 "Number of IAP Projects completed by 11-12"
lab var ExpenditureinRsLakh12 "IAP Expenditure in 100,0000 Rs by 11-12"
lab var any_iap  "District with at least one IAP projects"

lab var r_tot_pop "Rural population, 2001"
lab var tot_pop "Total population, 2001"
lab var r_tot_lit_rate "Percentage Literates, Rural, 2001"
lab var r_tot_scst_rate "ST/SC rate, Rural, 2001"
lab var r_tot_anyag_rate  "Rate of agricultural workers, Rural, 2001"
lab var pop_dens "Population Density (per sq km), 2001"
lab var r_share  "Share of the rural population, 2001"
lab var dist_pct_power  "Electrified villages (share), 2001"
lab var percentage_drought  "Drought prone (percentage of area), 2006"
lab var dist_pct_app_pr  "Villages connected by paved road (share), 2001"
lab var percentageforest  "Percentage of forest area, 2005"




egen hdate_st=group(st_code hdate)
egen st_dist=group(state district)

gen mainsample_full= inrange(hdate,94,107) 
label var mainsample_full "Main sample 2007-2013"

gen mainsample_window= inrange(hdate,94,103) 
label var mainsample_window "Main sample 2007-2011"


* Labels
*--------

label var st_code "State code, 2001 Census"
label var dist_code "District code 2001 Census"
lab var bauxdepdum "Bauxite Deposits (0-1)"
lab var coaldepdum "Coal Deposits (0-1)"
lab var irondepdum "Iron Deposits (0-1)"
lab var bauxitedepdum "Bauxite Deposits (0-1)"
lab var manganesedepdum "Manganese Deposits (0-1)"
lab var chromitedepdum "Chromite Deposits (0-1)"
lab var iron_post "Iron Deposit x Post"
lab var baux_post "Bauxite Deposit x Post"
lab var coal_post "Coal Deposit x Post"
lab var manganese_post "Manganese Deposit x Post"
lab var chromite_post "Chromite Deposit x Post"
lab var log_irondep_post "Log(Iron Deposit) x Post"
lab var log_bauxdep_post "Log(Bauxite Deposit) x Post"
lab var log_coaldep_post "Log(Coal Deposit) x Post"
lab var log_irondep1000_post "Log(Iron Deposit*1000) x Post"
lab var log_bauxdep1000_post "Log(Bauxite Deposit*1000) x Post"
lab var log_coaldep1000_post "Log(Coal Deposit*1000) x Post"
lab var log_irondepdiv1000_post "Log(Iron Deposit/1000) x Post"
lab var log_bauxdepdiv1000_post "Log(Bauxite Deposit/1000) x Post"
lab var log_coaldepdiv1000_post "Log(Coal Deposit/1000) x Post"
lab var log_irondep100_post "Log(Iron Deposit*100) x Post"
lab var log_bauxdep100_post "Log(Bauxite Deposit*100) x Post"
lab var log_coaldep100_post "Log(Coal Deposit*100) x Post"
lab var log_irondepdiv100_post "Log(Iron Deposit/100) x Post"
lab var log_bauxdepdiv100_post "Log(Bauxite Deposit/100) x Post"
lab var log_coaldepdiv100_post "Log(Coal Deposit/100) x Post"
lab var log_irondep10_post "Log(Iron Deposit*10) x Post"
lab var log_bauxdep10_post "Log(Bauxite Deposit*10) x Post"
lab var log_coaldep10_post "Log(Coal Deposit*10) x Post"
lab var log_irondepdiv10_post "Log(Iron Deposit/10) x Post"
lab var log_bauxdepdiv10_post "Log(Bauxite Deposit/10) x Post"
lab var log_coaldepdiv10_post "Log(Coal Deposit/10) x Post"
lab var iron_value1000 "Log(Iron Deposit*1000) x Price (real USD per MT)"
lab var baux_value1000 "Log(Bauxite Deposit*1000) x Price (real USD per MT)"
lab var coal_value1000 "Log(Coal Deposit*1000) x Price (real USD per MT)"
lab var iron_valuediv1000 "Log(Iron Deposit/1000) x Price (real USD per MT)"
lab var baux_valuediv1000 "Log(Bauxite Deposit/1000) x Price (real USD per MT)"
lab var coal_valuediv1000 "Log(Coal Deposit/1000) x Price (real USD per MT)"
lab var iron_value100 "Log(Iron Deposit*100) x Price (real USD per MT)"
lab var baux_value100 "Log(Bauxite Deposit*100) x Price (real USD per MT)"
lab var coal_value100 "Log(Coal Deposit*100) x Price (real USD per MT)"
lab var iron_valuediv100 "Log(Iron Deposit/100) x Price (real USD per MT)"
lab var baux_valuediv100 "Log(Bauxite Deposit/100) x Price (real USD per MT)"
lab var coal_valuediv100 "Log(Coal Deposit/100) x Price (real USD per MT)"
lab var iron_value10 "Log(Iron Deposit*10) x Price (real USD per MT)"
lab var baux_value10 "Log(Bauxite Deposit*10) x Price (real USD per MT)"
lab var coal_value10 "Log(Coal Deposit*10) x Price (real USD per MT)"
lab var iron_valuediv10 "Log(Iron Deposit/10) x Price (real USD per MT)"
lab var baux_valuediv10 "Log(Bauxite Deposit/10) x Price (real USD per MT)"
lab var coal_valuediv10 "Log(Coal Deposit/10) x Price (real USD per MT)"
lab var log_irondep "Log(Iron Deposit)"
lab var log_bauxdep "Log(Bauxite Deposit)"
lab var log_coaldep "Log(Coal Deposit)"
lab var iron_price "Iron Deposit x Price (real USD per MT)"
lab var baux_price "Bauxite Deposit x Price (real USD per MT)"
lab var coal_price "Coal Deposit x Price (real USD per MT)"
lab var manganese_price "Mangangese Deposit x Price (real USD per MT)"
lab var chromite_price "Chromite Deposit x Price (real USD per MT)"
lab var iron_value "Log(Iron Deposit) x Price (real USD per MT)"
lab var baux_value "Log(Bauxite Deposit) x Price (real USD per MT)"
lab var coal_value "Log(Coal Deposit) x Price (real USD per MT)"
label var pop_dens "Population density (100 per sq km)"
label variable hdate "Half year"
label variable border_sample "Districts containing or bordering iron ore districts"
label variable minesample "Districts for which mine measures are in the mine sample"
label variable _X "District Longitude"
label variable _Y "District Latitude"

format hdate %th

keep state district _X _Y r_tot_pop border_sample minesample ///
 post st_dist dist_code st_code hdate tot_pop antiattack attack percentageforest NumberofProjectssanctioned12 NumberofProjectstakenup12 ///
 NumberofProjectsCompleted12 ExpenditureinRsLakh12 q_avg_p_baux q_avg_p_coal q_avg_p_ironore ///
 manganesedepdum chromitedepdum irondepdum bauxitedepdum coaldepdum bauxdepdum log_irondep log_bauxdep log_coaldep log_irondep_post  log_coaldep_post ///
 log_irondep* log_bauxdep* log_coaldep* iron_post baux_post coal_post manganese_post chromite_post log_antiattack log_attack hyp_attack hyp_antiattack attack_d antiattack_d iron_price coal_price baux_price ///
 iron_value* coal_value* baux_value* manganese_price chromite_price ///
irondep94 irondepdum94 irondep95 irondepdum95 irondep96 irondepdum96 irondep97 irondepdum97 irondep98 irondepdum98 irondep99 irondepdum99 irondep100 irondepdum100 irondep101 irondepdum101 irondep102 irondepdum102 irondep103 irondepdum103 irondep104 irondepdum104 irondep105 irondepdum105 irondep106 irondepdum106 irondep107 irondepdum107 bauxdep94 bauxdepdum94 bauxdep95 bauxdepdum95 bauxdep96 bauxdepdum96 bauxdep97 bauxdepdum97 bauxdep98 bauxdepdum98 bauxdep99 bauxdepdum99 bauxdep100 bauxdepdum100 bauxdep101 bauxdepdum101 bauxdep102 bauxdepdum102 bauxdep103 bauxdepdum103 bauxdep104 bauxdep105 bauxdepdum104 bauxdepdum105 bauxdep106 bauxdepdum106 bauxdep107 bauxdepdum107 coaldep94 coaldepdum94 coaldep95 coaldepdum95 coaldep96 coaldepdum96 coaldep97 coaldepdum97 coaldep98 coaldepdum98 coaldep99 coaldepdum99 coaldep100 coaldepdum100 coaldep101 coaldepdum101 coaldep102 coaldepdum102 coaldep103 coaldepdum103 coaldep104 coaldepdum104 coaldep105 coaldepdum105 coaldep106 coaldepdum106 coaldep107 coaldepdum107 ///
 r_tot_lit_rate pop_dens dist_pct_app_pr r_tot_scst_rate mainsample_full mainsample_window hdate_st attack_pc antiattack_pc ///
any_iap coal_price_st baux_price_st iron_price_st iron2* ///
coal2_post coalsmalldrop* bauxsmalldrop* ironsmalldrop* baux2_post iron2_post iron2_price baux2_price coal2_price ///
r_share r_tot_anyag_rate percentage_drought dist_pct_power_supl

save "FINAL_Replication_Conflict", replace


*****************************
* 2. Create Final_Output.dta
*****************************

preserve
import delimited "INPUT_Output.csv", clear 
gen log_iron_output=log(iron_output/1000)
* Output data from US geological survey, in 1000 metric tonnes, make it million
label var log_iron_output "Log Iron Output"
drop iron_output
label var year "Year"
save "FINAL_Replication_Output", replace
restore


* END






